package com.xxxx.server.controller;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;

import com.xxxx.server.pojo.*;
import com.xxxx.server.service.impl.EmployeeServiceImpl;
import com.xxxx.server.service.impl.SalaryServiceImpl;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 员工账套
 *
 * @author zhoubin
 * @since 1.0.0
 */
@Api("员工账套")
@RestController
@RequestMapping("/salary/sobcfg")
public class SalarySobCfgController {

    @Resource
    private SalaryServiceImpl salaryService;
    @Resource
    private EmployeeServiceImpl employeeService;

    /**
     * 分页查询
     *
     * @return
     */
    @ApiOperation(value = "员工帐套查询")
    @GetMapping("/")
    public Map<String, Object> selectAllEmployee(EmployeeVo employeeVo) {
        return salaryService.selectAllEmployee(employeeVo);
    }

    //获取所有账套
    @GetMapping("/salaries")
    public List<Salary> selectAll() {
        return salaryService.list();
    }


    /**
     * 修改工工资账套
     */

    @PutMapping("/")
    public RespBean updateEmployeeSalary(Emp_sidVo emp_sidVo) {
        String eid=emp_sidVo.getEid();
        String sid=emp_sidVo.getSid();

        System.out.println(eid+","+sid);
        boolean update = employeeService.update(new UpdateWrapper<Employee>().set("salaryid", sid).eq("id", eid));
        if (update) {
            return RespBean.success("更新成功");
        } else {
            return RespBean.error("更新失败");
        }
    }



}

